<template>
    <div class="Discount-Page">
      <div class="panel-body">
        <input class="form-control" v-model="search" style="width: 400px;float:left" placeholder="搜索会员等级名">
        <el-button type="primary" style="float: right">添加会员等级<i class="el-icon-upload el-icon--right"></i></el-button>
      </div>
      <el-table :data="discountList">
        <el-table-column prop="id" label="会员等级编号"/>
        <el-table-column prop="level" label="会员等级名称"/>
        <el-table-column prop="discount" label="会员等级价格"/>
        <el-table-column label="会员等级操作">
          <template scope="scope">
            <router-link :to="'/'+scope.row.id">编辑</router-link>
            <router-link :to="'/'+scope.row.id">删除</router-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
</template>

<script>
    export default {
        name: 'discountList',
      data(){
        return {
          search:'',
          discount:[]
        }
      },
      computed:{
        discountList(){
          return this.discount.filter(shop=>{
            return shop.level.indexOf(this.search)!=-1
          });
        }
      },
      mounted() {
        this.$http.get('/discount').then(resp=>{
          this.discount = resp.data;
        }).catch(err=>console.log(err));
      }
    }
</script>
<style lang="less">
    .Discount-Page {
    }
</style>
